<template>
  <div>
      作者名<input type="text" v-model="username">
      密码<input type="password" v-model="password">
      <input type="button" @click="btn" value="登录">
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
          username:'',
            password:''
        }
    },methods:{
        btn(){
            const fd={
                'username':this.username,
                'password':this.password
            }
          axios.post('http://127.0.0.1:8000/login1',fd).then(resp=>{
              console.log(resp.data)
                alert(resp.data.msg)
                if(resp.data.status==200){
                    this.$router.push('/index1')
                    sessionStorage.setItem('uid',resp.data.uid)
                    sessionStorage.setItem('username',this.username)
                }    
          }).catch(error=>{
              console.log(error)
          })
        }
    }
}
</script>

<style>

</style>